<?php

class Model_Color extends Model {
    
    private $table = "colors";
    
    public function getColorsList()
    {
        $sql = "SELECT * FROM {$this->table}";
        return $this->db->query($sql)->fetchAll();
    }
    
    public function getColorsForProduct($id)
    {
        $sql = "SELECT c.* FROM {$this->table} AS c LEFT JOIN products_colors AS pc ON pc.color_id = c.id 
                    WHERE pc.product_id = ?";
        return $this->db->query($sql, $id);
    }
}